/*
 *  Calibration.h
 *  portVideoBlobDetection
 *
 *  Created by Pawe? So?yga on 7/23/07.
 *  Copyright 2007 __MyCompanyName__. All rights reserved.
 *
 */
#ifndef __CALIBRATION_H__
#define __CALIBRATION_H__
#include "TouchData.h"
#include <string>

class Calibration
{
private:
	bool isOn;
	
	float proportionWidth;
	float proportionHeight;
	
	TouchData leftUpCorner, downRightCorner;

	void resizeUp( float amount); // 1/height - 1 pixel
	void resizeDown( float amount); // 1/height
	void resizeLeft( float amount); // 1/width
	void resizeRight( float amount); // 1/width
	
	void moveUp( float amount);
	void moveDown( float amount);
	void moveLeft( float amount);
	void moveRight( float amount);
	
	void calculateCoordinates(TouchData &td);
	void calculateProportions();

public:
	enum MODES { CORNER_MODE, CENTER_MODE } mode;
	enum SIDES { UP, DOWN, LEFT, RIGHT };
	Calibration();
	
	void setScreenRect(TouchData luc, TouchData drc);
	void getScreenRect(TouchData &luc, TouchData &drc);
	void setOn(bool isOn);
	bool cameraToScreen(TouchData &td);
	bool isInRect(TouchData &td);
	void setMode(Calibration::MODES newMode); //center or corner
	void resize(Calibration::SIDES what, float howmuch);
	void move(Calibration::SIDES where, float howmuch);
	
	bool readConfig(std::string configFile);
	bool saveConfig(std::string configFile);

};

#endif